package rooms.southPod;

import actions.Direction;
import rooms.Room;
import exceptions.MudExceptions;
import mobs.NPC;
import items.Item;

import java.util.ArrayList;
import java.util.List;

public class NorthEastCornerHallway implements Room {
    private static Room me;

    private List<NPC> mobs = new ArrayList<NPC>();
    private List<Item> items = new ArrayList<Item>();

    public static synchronized Room getInstance() {
        if (me == null) {
            me = new NorthEastCornerHallway();
        }
        return me;
    }

    public String getTitle() {
        return "Northeast Corner Hallway";
    }

    public String getDescription() {
        return "You are in the corner of the hallway.";
    }

    public String getLongDescription() {
        return "This corner of the hall is obviously less traveled than the northwest corner, but still receives some traffic." +
                " There is a locked door to the north, an open door to the east and continuing exits to the west and south.";
    }

    @Override
    public Room getRoomMove(Direction direction) {
        Room room;
        if (direction == Direction.NORTH) {
            room = ServerRoom.getInstance();
        } else if (direction == Direction.SOUTH){
            room = EastHallway1.getInstance();
        } else if (direction == Direction.WEST) {
            room = ReceptionistsLobby.getInstance();
        } else if (direction == Direction.EAST) {
            room = TrainingRoom.getInstance();
        } else if (direction == Direction.DOWN) {
            throw MudExceptions.invalidMoveDown();
        } else if (direction == Direction.UP) {
            throw MudExceptions.invalidMoveUp();
        } else {
            throw MudExceptions.invalidMove();
        }
        return room;
    }

    public List<NPC> getActiveNPCs() {
        return mobs;
    }

    public String showMobs() {
        StringBuffer rtn = new StringBuffer();
        for (NPC npc : getActiveNPCs()) {
            rtn.append(npc.getName());
            rtn.append("\n");
        }
        return rtn.toString();
    }

    public List<Item> getRoomItems() {
        return items;
    }

     public String showItems() {
        StringBuffer rtn = new StringBuffer();
        for (Item item : getRoomItems()) {
            rtn.append(item.getTitle());
            rtn.append("\n");
        }
        return rtn.toString();
    }
}